package com.pine.manager.pineframework.convertors;

import com.pine.common.beans.pineframework.request.SysApprovalApplicationQueryRequest;
import com.pine.common.beans.pineframework.request.SysApprovalApplicationSaveOrUpdateRequest;
import com.pine.common.beans.pineframework.response.SysApprovalApplicationQueryResponse;
import com.pine.common.convertor.EntityConvertor;
import com.pine.common.convertor.QueryConvertor;
import com.pine.common.convertor.SaveConvertor;
import com.pine.dao.pineframework.constants.ApprovalStatusEnum;
import com.pine.dao.pineframework.entity.SysApprovalApplication;
import com.pine.manager.pineframework.bo.SysApprovalApplicationBo;
import com.pine.manager.pineframework.query.SysApprovalApplicationQuery;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;

import java.util.Objects;

/**
 * <p>
 * 系统审批申请表 转换器
 * </p>
 *
 * @author pine manage
 * @since 2024-10-31
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class SysApprovalApplicationConvertor implements EntityConvertor<SysApprovalApplication, SysApprovalApplicationBo>,
        QueryConvertor<SysApprovalApplicationBo, SysApprovalApplicationQuery, SysApprovalApplicationQueryRequest, SysApprovalApplicationQueryResponse>,
        SaveConvertor<SysApprovalApplicationBo, SysApprovalApplicationSaveOrUpdateRequest> {

    public ApprovalStatusEnum integerToApprovalStatusEnum(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        return ApprovalStatusEnum.of(code);
    }

    public Integer approvalStatusEnumToInteger(ApprovalStatusEnum statusEnum) {
        if (Objects.isNull(statusEnum)) {
            return null;
        }
        return statusEnum.getCode();
    }
}
